<template>
  <div class="mobile-stats">
    <div v-fade-in class="hero-title">天启明通·致力于成为卓越的智慧城市服务商</div>
    <M-button v-slide-up @click="handleDetail" />
    <div v-if="data?.length > 0" v-slide-up class="stats-bottom">
      <div class="bottom-center">
        <div
          v-slide-plus
          v-for="(item, index) in data"
          :key="index"
          class="bottom-item"
          :class="{
            'left-offset': index % 2 === 0,
            'right-offset': index % 2 !== 0,
          }"
        >
          <div class="bottom-item-value">
            <Count-to :end="item.value" /><span>{{ item.unit }}</span>
          </div>
          <div class="bottom-item-label">{{ item.title }}</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { useRouter } from "vue-router";

const router = useRouter();

defineProps({
  data: {
    type: Array as PropType<any[]>,
    default: () => [],
  },
});

// 跳转详情
const handleDetail = () => {
  router.push("/m/about");
};
</script>
<style lang="scss" scoped>
.mobile-stats {
  width: 100%;
  background: url("@/assets/home/carousel2.png") no-repeat;
  background-size: cover;
  height: 100vh;
  position: relative;
  box-sizing: border-box;
  .stats-bottom {
    position: absolute;
    bottom: 20px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .bottom-center {
    width: calc(100% - 2.5rem);
    height: 50vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    &::before {
      content: "";
      position: absolute;
      top: 0;
      bottom: 0;
      left: 50%;
      width: 1px;
      background: rgba(255, 255, 255, 0.33);
    }
  }
  .bottom-item {
    width: calc(50% - 1px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 5rem;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.33);
    transition: all 1s;

    &-value {
      font-size: 33px;
      font-weight: 700;
      line-height: 33px;
      color: #fff;
      span {
        font-size: 18px;
      }
    }
    &-label {
      font-size: 18px;
      line-height: 28px;
      color: #fff;
    }
  }
  .left-offset {
    align-self: flex-start;
  }
  .right-offset {
    align-self: flex-end;
  }

  .hero-title {
    position: absolute;
    left: 1.25rem;
    right: 1.25rem;
    top: 15%;
    font-size: 22px;
    font-weight: 700;
    line-height: 32px;
    color: #fff;
    z-index: 4;
  }
  :deep(.more-btn) {
    position: absolute;
    left: 1.25rem;
    top: 25%;
    z-index: 4;
  }
}
</style>
